import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {path: '/', redirect:'/login'},  //重定向的方式设置默认跳转路由
    // {path: '/Manager', component:() =>import('../views/Manager.vue'),children:[
    //   {path: 'home', name: 'home',meta:{title:'主页'}, component:() =>import('../views/Home.vue')},
    //   {path: 'test', name: 'test',meta:{title:'测试数据页面'}, component:() =>import('../views/Test.vue')},
    //   {path: 'data', name: 'data',meta:{title:'数据展示页面'}, component:() =>import('../views/Data.vue')},
    //   {path: 'employee', name: 'employee',meta:{title:'员工的信息页面'}, component:() =>import('../views/Employee.vue')},
    //   {path: 'admin', name: 'admin',meta:{title:'管理员的信息页面'}, component:() =>import('../views/Admin.vue')},
    //   {path: 'student', name: 'student',meta:{title:'学生管理页面'}, component:() =>import('../views/Student-manage.vue')},
    //   {path: 'person', name: 'person',meta:{title:'个人信息页面'}, component:() =>import('../views/Person.vue')},
    //   {path: 'password', name: 'password',meta:{title:'修改密码页面'}, component:() =>import('../views/Password.vue')},
    //   {path: 'article', name: 'article',meta:{title:'文章信息页面'}, component:() =>import('../views/Article.vue')},
    //   {path: 'department', name: 'department',meta:{title:'部门信息'}, component:() =>import('../views/Department.vue')},
    // ]},
      {path: '/student', component:() =>import('../views/Student.vue'),children:[
              {path: 'home', name: 'student-home',meta:{title:'主页'}, component:() =>import('../views/Home.vue')},
              {path: 'clubs', name: 'clubs-student',meta:{title:'社团'}, component:() =>import('../views/Clubs.vue')},
              {path: 'my-club', name: 'my-club-student',meta:{title:'社团'}, component:() =>import('../views/My-club.vue')},
              {path: 'notification', name: 'notification-student',meta:{title:'消息通知'}, component:() =>import('../views/Notification.vue')},
              {path: 'person', name: 'person-student',meta:{title:'个人信息'}, component:() =>import('../views/Person.vue')},
              {path: 'password', name: 'password-student',meta:{title:'修改密码'}, component:() =>import('../views/Password.vue')},
              {path: 'clubs-all', name: 'clubs-all-student',meta:{title:'所有社团展示'}, component:() =>import('../views/Clubs-all.vue')},
              {path: 'recruitment-application', name: 'recruitment-application-student',meta:{title:'活动报名'}, component:() =>import('../views/Recruitment-application.vue')},
              {path: 'recruitment-registration', name: 'recruitment-registration-student',meta:{title:'招募报名'}, component:() =>import('../views/Recruitment-registration.vue')},
          ]},
      {path: '/president', component:() =>import('../views/President.vue'),children:[
              {path: 'home', name: 'manager-home',meta:{title:'主页'}, component:() =>import('../views/Home.vue')},
              {path: 'clubs', name: 'clubs-president',meta:{title:'社团'}, component:() =>import('../views/Clubs.vue')},
              {path: 'my-club', name: 'my-club-president',meta:{title:'社团'}, component:() =>import('../views/My-club.vue')},
              {path: 'notification', name: 'notification-president',meta:{title:'消息通知'}, component:() =>import('../views/Notification.vue')},
              {path: 'person', name: 'person-president',meta:{title:'个人信息'}, component:() =>import('../views/Person.vue')},
              {path: 'password', name: 'password-president',meta:{title:'修改密码'}, component:() =>import('../views/Password.vue')},
              {path: 'clubs-all', name: 'clubs-all-president',meta:{title:'所有社团展示'}, component:() =>import('../views/Clubs-all.vue')},
              {path: 'recruitment-application', name: 'recruitment-application-president',meta:{title:'招募申请表'}, component:() =>import('../views/Recruitment-application.vue')},
              {path: 'club-manage', name: 'club-manage-president',meta:{title:'社团管理'}, component:() =>import('../views/Club-manage.vue')},
              {path: 'members', name: 'members-president',meta:{title:'社团成员管理'}, component:() =>import('../views/Clubmember-manage.vue')},
              {path: 'event-manage', name: 'event-manage-president',meta:{title:'活动管理'}, component:() =>import('../views/Event-manage.vue')},
              {path: 'applications', name: 'applications-president',meta:{title:'审批管理'}, component:() =>import('../views/Applications.vue')},
              {path: 'recruitment-manage', name: 'recruitment-manage-president',meta:{title:'招募管理'}, component:() =>import('../views/Recruitment-manage.vue')},
          ]},
      {path: '/admin', component:() =>import('../views/Admin.vue'),children:[
              {path: 'admin-manage', name: 'admin-manage',meta:{title:'管理员管理'}, component:() =>import('../views/Admin-manage.vue')},
              {path: 'student-manage', name: 'student-manage',meta:{title:'学生管理'}, component:() =>import('../views/Student-manage.vue')},
              {path: 'club-manage', name: 'club-manage',meta:{title:'社团管理'}, component:() =>import('../views/Club-manage.vue')},
              {path: 'person', name: 'person-admin',meta:{title:'个人信息页面'}, component:() =>import('../views/Person.vue')},
              {path: 'password', name: 'password--admin',meta:{title:'修改密码页面'}, component:() =>import('../views/Password.vue')},
              {path: 'clubmember-manage', name: 'clubmember-manage',meta:{title:'社团成员管理'}, component:() =>import('../views/Clubmember-manage.vue')},
              
              {path: 'event-manage', name: 'event-manage-admin', meta:{title:'活动管理'}, component:() =>import('../views/Event-manage.vue')},

              // The following routes are commented out because the corresponding component files were not clearly identified.
              // Please uncomment and update the component path if you find the correct file.
              // {path: 'president-manage', name: 'president-manage', meta:{title:'社长管理'}, component:() =>import('../views/President-manage.vue')},
              // {path: 'notification-manage', name: 'notification-manage-admin', meta:{title:'消息管理'}, component:() =>import('../views/Notification-manage.vue')},
              // {path: 'activity-application-manage', name: 'activity-application-manage', meta:{title:'活动申请管理'}, component:() =>import('../views/Activity-application-manage.vue')},

              // Added President Management route based on user request
              {path: 'president-manage', name: 'president-manage', meta:{title:'社长管理'}, component:() =>import('../views/President-manage.vue')},

          ]},

        {path: '/overiew', name: 'overiew',meta:{title:'概览'}, component:() =>import('../views/Overview.vue')},
        {path: '/wangEditor', name: 'wangEditor',meta:{title:'评论'}, component:() =>import('../views/WangEditor.vue')},
        {path: '/login', name: 'login',meta:{title:'登录系统'}, component:() =>import('../views/Login.vue')},//登录页面是整个页面，要放在manager的外面
        {path: '/register', name: 'register',meta:{title:'注册系统'}, component:() =>import('../views/Register.vue')},
        {path: '/404', name: 'Notfound',meta:{title:'找不到页面'}, component:() =>import('../views/404.vue')},
        {path: '/:pathMatch(.*)', redirect:'/404'}
  ]
})
//表示跳转之前的操作
router.beforeEach((to,from,next)=>{
  document.title=to.meta.title
  next() //必须调用这个函数才能实现跳转
})

export default router
